import {h} from "vue";
import {NTag} from "naive-ui";

export const columns = [
  {
    title: 'ID',
    key: 'id',
    width: 180,
  },
  {
    title: '所属分组',
    key: 'collect',
    width: 100,
  },
  {
    title: '权限名称',
    key: 'name',
    width: 100,
  },
  {
    title: '请求方式',
    key: 'rest',
    width: 100,
    render(row) {
      if(row.rest == "GET") {
        return h(
          NTag, {
            type: "info",
          }, {
            default: () => ("GET"),
          }
        );
      }
      if(row.rest == "POST") {
        return h(
          NTag, {
            type: "success",
          }, {
            default: () => ("POST"),
          }
        );
      }
      if(row.rest == "PUT") {
        return h(
          NTag, {
            type: "warning",
          }, {
            default: () => ("PUT"),
          }
        );
      }
      if(row.rest == "DELETE") {
        return h(
          NTag, {
            type: "error",
          }, {
            default: () => ("DELETE"),
          }
        );
      }
    }
  },
  {
    title: '权限标记',
    key: 'mark',
    width: 200,
  },
  {
    title: '状态',
    key: 'status',
    width: 100,
    render(row) {
      return h(
        NTag,
        {
          type: row.status ? 'success' : 'error',
        },
        {
          default: () => (row.status ? '启用' : '禁用'),
        }
      );
    },
  },
  {
    title: '创建人',
    key: 'createBy',
    width: 100,
  },
  {
    title: '创建时间',
    key: 'createTime',
    width: 180,
  },
  {
    title: '更新人',
    key: 'updateBy',
    width: 100,
  },
  {
    title: '更新时间',
    key: 'updateTime',
    width: 180,
  },
];
